﻿@model blacksoft.Models.ArqueoDeCaja
@using blacksoft.Helpers


@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_LayoutVentas.cshtml";
}



<div class="block big">
    <div class="titlebar">
        <h3>Nueva Promoción</h3>
    </div>
    <div class="block_cont">

        @using (Html.BeginForm())
        {
            @Html.AntiForgeryToken()

            <div class="form">
                @Html.ValidationSummary(true)
                @Html.HiddenFor(model => model.IDPersona)
                @Html.HiddenFor(model => model.IDUnidadVenta)

                <div class="form-row">
                    @Html.LabelFor(model => model.FechaArqueo)
                    @Html.TextBoxFor(model => model.FechaArqueo, new { @class = "text-box single-line", @disabled = "disabled" })
                    @Html.HiddenFor(model => model.FechaArqueo)
                    @Html.ValidationMessageFor(model => model.FechaArqueo)
                </div>

                <div class="form-row">
                    @Html.LabelFor(model => model.MontoNotaCredito)
                    @Html.TextBoxFor(model => model.MontoNotaCredito, new { @class = "text-box single-line", @disabled = "disabled" })
                    @Html.HiddenFor(model => model.MontoNotaCredito)
                    @Html.ValidationMessageFor(model => model.MontoNotaCredito)
                </div>

                <div class="form-row">
                    @Html.LabelFor(model => model.MontoSoles)
                    @Html.TextBoxFor(model => model.MontoSoles, new { @class = "text-box single-line", @disabled = "disabled" })
                    @Html.HiddenFor(model => model.MontoSoles)
                    @Html.ValidationMessageFor(model => model.MontoSoles)
                </div>

                <div class="form-row">
                    @Html.LabelFor(model => model.MontoDolares)
                    @Html.TextBoxFor(model => model.MontoDolares, new { @class = "text-box single-line", @disabled = "disabled" })
                    @Html.HiddenFor(model => model.MontoDolares)
                    @Html.ValidationMessageFor(model => model.MontoDolares)
                </div>

                <div class="form-row">
                    @Html.LabelFor(model => model.MontoSistema)
                    @Html.TextBoxFor(model => model.MontoSistema, new { @class = "operando text-box single-line", @disabled = "disabled" })
                    @Html.HiddenFor(model => model.MontoSistema)
                    @Html.ValidationMessageFor(model => model.MontoSistema)
                </div>

                <div class="form-row">
                    @Html.LabelFor(model => model.montoConteo)
                    @Html.TextBoxFor(model => model.montoConteo, new { @class = "operando text-box single-line" })
                    @Html.ValidationMessageFor(model => model.montoConteo)
                </div>

                <div class="form-row">
                    @Html.LabelFor(model => model.Descuadre)
                    @Html.TextBoxFor(model => model.Descuadre, new { @class = "operando text-box single-line", @readonly = "readonly", @style = "background:#cccccc;" })
                    @Html.HiddenFor(model => model.Descuadre)
                    @Html.ValidationMessageFor(model => model.Descuadre)
                </div>

                <div class="form-row">
                    <div class="col-md-offset-2 col-md-10">
                        <input type="submit" value="Registrar" class="btn btn-default" onclick="return confirm('¿Desea registrar este Arqueo de Caja?')" />
                    </div>
                </div>
            </div>
        }

        <div>
            @Html.ActionLink("Regresar a listado", "Index")
        </div>
    </div>
</div>

<script>
    jQuery(window).load(function () {
        var l = parseFloat($("#MontoSistema").val() || 0);
        var f = parseFloat($("#montoConteo").val() || 0);


        var total = l - f;
        var s_total = total.toFixed(2);
        if (s_total < 0) {
            total = f - l;
            s_total = total.toFixed(2);
            $("#Descuadre").val(parseFloat(s_total));
        }
        else
            $("#Descuadre").val(parseFloat(s_total));
    });

    $(document).ready(
        $(".operando").keyup(function () {
            var l = parseFloat($("#MontoSistema").val() || 0);
            var f = parseFloat($("#montoConteo").val() || 0);

            var total = l - f;
            var s_total = total.toFixed(2);
            if (s_total < 0) {
                total = f - l;
                s_total = total.toFixed(2);
                $("#Descuadre").val(parseFloat(s_total));
            }
            else
                $("#Descuadre").val(parseFloat(s_total));
    }));
</script>